import React from "react";
import axios from "axios";

let fundId = window.location.href;
fundId = fundId.toString().split('=');
if (fundId.length == 2){
    fundId = fundId[1] + '';
}
let zeronum = 0
for(var i=0;i<fundId.length;i++){
    if(fundId[i] == 0){
        zeronum = zeronum+1;
    }else {
        break;
    }
}
console.log(zeronum)
fundId = fundId.slice(zeronum,)
console.log(fundId)

export default class Fund_record extends React.Component{
    constructor(props) {
        super(props);
        this.state={
            fund_data:[],
        };
        var FUNDID=window.location.href.split('=')[1];
        axios.get(global.routes.database+'/getFunds', {
            params: {
                fundID: FUNDID,
            }
        }).then((res)=>{

            switch (res.data.Data.FCODE.toString().length) {
                case 1:
                    res.data.Data.FCODE = '00000'+res.data.Data.FCODE.toString();
                    break;
                case 2:
                    res.data.Data.FCODE = '0000'+res.data.Data.FCODE.toString();
                    break;
                case 3:
                    res.data.Data.FCODE = '000'+res.data.Data.FCODE.toString();
                    break;
                case 4:
                    res.data.Data.FCODE = '00'+res.data.Data.FCODE.toString();
                    break;
                case 5:
                    res.data.Data.FCODE = '0'+res.data.Data.FCODE.toString();
                    break;
                case 6:
                    res.data.Data.FCODE = res.data.Data.FCODE.toString();
                    break;
            }

            this.setState({
                fund_data:res.data.Data,
            });
        })
        ;
    };

    render() {
        return(
            <div style={{width:'100%%',margin:'0',padding:'0',height:'180px'}}>
                <div style={{width:'100%',margin:'10px 0 0 0',padding:'0'}}>
                    <h2 style={{fontSize:'16px',fontWeight:'bold',margin:'0 auto 0 30px',padding:'0',lineHeight:'30px'}}>基金档案</h2>
                </div>
                <div style={{width:'100%',margin:'0',padding:'0'}}>
                    <ul style={{width:'100%',listStyle:'none',margin:'0',padding:'0 30px 0 30px',float:'left',textAlign:'center',fontSize:'14px',lineHeight:'30px',borderBottom:'0.5px solid lightgray'}}>
                        <li style={{width:'40%',float:'left',margin:'0',padding:'0'}}>基金名称</li>
                        <li style={{width:'60%',float:'left',margin:'0',padding:'0'}}>{this.state.fund_data.SHORTNAME}</li>
                    </ul>
                    <ul style={{width:'100%',listStyle:'none',margin:'0',padding:'0 30px 0 30px',float:'left',textAlign:'center',fontSize:'14px',lineHeight:'30px',borderBottom:'0.5px solid lightgray'}}>
                        <li style={{width:'40%',float:'left',margin:'0',padding:'0'}}>基金代码</li>
                        <li style={{width:'60%',float:'left',margin:'0',padding:'0'}}>{this.state.fund_data.FCODE}</li>
                    </ul>
                    <ul style={{width:'100%',listStyle:'none',margin:'0',padding:'0 30px 0 30px',float:'left',textAlign:'center',fontSize:'14px',lineHeight:'30px',borderBottom:'0.5px solid lightgray'}}>
                        <li style={{width:'40%',float:'left',margin:'0',padding:'0'}}>基金公司</li>
                        <li style={{width:'60%',float:'left',margin:'0',padding:'0'}}>{this.state.fund_data.JJGS}管理公司</li>
                    </ul>
                    <ul style={{width:'100%',listStyle:'none',margin:'0',padding:'0 30px 0 30px',float:'left',textAlign:'center',fontSize:'14px',lineHeight:'30px',borderBottom:'0.5px solid lightgray'}}>
                        <li style={{width:'40%',float:'left',margin:'0',padding:'0'}}>基金经理</li>
                        <li style={{width:'60%',float:'left',margin:'0',padding:'0'}}>{this.state.fund_data.JJJL}</li>
                    </ul>
                    <ul style={{width:'100%',listStyle:'none',margin:'0',padding:'0 30px 0 30px',float:'left',textAlign:'center',fontSize:'14px',lineHeight:'30px',borderBottom:'0.5px solid lightgray'}}>
                        <li style={{width:'40%',float:'left',margin:'0',padding:'0'}}>基金规模</li>
                        <li style={{width:'60%',float:'left',margin:'0',padding:'0'}}>{this.state.fund_data.FEGM}元</li>
                    </ul>
                </div>
            </div>
        )
    }
}